using System;
using UnityEngine;
using Unity.VisualScripting;
using ResourceUpdateChangedEventArgs = UnityGameFramework.Runtime.ResourceUpdateChangedEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Update")]
    [UnitSurtitle("Changed")]
    public sealed class ResourceUpdateChanged : FrameworkEventUnit<ResourceUpdateChangedEventArgs>
    {
        protected override int EventId => ResourceUpdateChangedEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceUpdateChanged;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadUri
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CurrentLength
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CompressedLength
        {
            get;
            private set;
        }

        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            DownloadPath = ValueOutput<string>(nameof(DownloadPath));
            DownloadUri = ValueOutput<string>(nameof(DownloadUri));
            CurrentLength = ValueOutput<int>(nameof(CurrentLength));
            CompressedLength = ValueOutput<int>(nameof(CompressedLength));
        }

        protected override void AssignArguments(Flow flow, ResourceUpdateChangedEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.Name);
            flow.SetValue(DownloadPath, args.DownloadPath);
            flow.SetValue(DownloadUri, args.DownloadUri);
            flow.SetValue(CurrentLength, args.CurrentLength);
            flow.SetValue(CompressedLength, args.CompressedLength);
        }
    }
}